<!--
  @Created by pangzg pangzg2@yusys.com.cn on 2020-3-31 14:22:49.
  @updated by
  @description 任务列表清单
-->
<div>
  <yu-panel :title="title">
    <el-form-q ref="queryJobRef" :field-data="queryFields" :buttons="queryButtons" class="task-query-form"></el-form-q>
    <yu-toolBar>
      <yu-button @click="infoFn">详情</yu-button>
      <yu-button @click="reloadData">刷新</yu-button>
      <yu-button @click="showFlowChart">作业流信息</yu-button>
      <yu-button v-if="redoBnt && buttonShow" @click="redoRunTask">重跑</yu-button>
      <yu-button v-if="interruptBnt && buttonShow" @click="interruptFlowChart">中断</yu-button>
      <yu-button v-if="forceSuccessBnt && buttonShow" @click="forceJobSuccess">强制成功</yu-button>
      <yu-button v-if="preValueBnt && buttonShow" @click="preValue">查看设置预置返回值</yu-button>
      <yu-button v-if="unPreValueBnt && buttonShow" @click="unPreValue">取消预置返回值</yu-button>
      <yu-button v-if="forceJobValueBnt && buttonShow" @click="forceJobValue">强制设置返回值</yu-button>
      <yu-button v-if="jobParamBnt && buttonShow" @click="jobParamClick">作业信息调整</yu-button>
      <yu-button v-if="jobPriorBnt && buttonShow" @click="jobPriorClick">优先级</yu-button>
    </yu-toolBar>
    <yu-xtable ref="refTable" row-number :data-url="dataUrl" selection-type="checkbox" @sort-change="sort" @row-dblclick="showJobInfo" @row-click="cellClick"
      :default-load="false" max-height="500">
      <yu-xtable-column label="应用系统" prop="appName" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="任务名称" prop="groupName" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="作业代码" prop="actionCode" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="作业名称" prop="actionName" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="周期时点" prop="cyclePnt" width="90"></yu-xtable-column>
      <yu-xtable-column label="任务状态" prop="runState" data-code="USE_TASK_RUN_STATE,USE_JOB_RUN_STATE"></yu-xtable-column>
      <yu-xtable-column label="作业状态" prop="jobState" :options="jobStateOptions"></yu-xtable-column>
      <yu-xtable-column label="开始时间" prop="enterTimeStr" width="200" :show-overflow-tooltip="true" sortable="custom"></yu-xtable-column>
      <yu-xtable-column label="开始运行时间" prop="beginTimeStr" width="200" :show-overflow-tooltip="true" sortable="custom"></yu-xtable-column>
      <yu-xtable-column label="总时长" prop="runningTime" width="150"></yu-xtable-column>
      <yu-xtable-column label="运行时长" prop="actualRunningTime" width="150"></yu-xtable-column>
    </yu-xtable>
  </yu-panel>
  <yu-xdialog title="作业信息" :visible.sync="visible" width="75%" element-loading-text="数据处理中">
    <yu-tabs type="border-card" v-model="tabsActiveName" v-loading="loading">
      <yu-tab-pane label="作业基本信息">
        <yu-xform ref="refBaseForm" v-model="baseFormData" class="formHeight" label-width="140px">
          <yu-xform-group>
            <yu-xform-item label="作业类型名称" ctype="select" data-code="USE_TASK_JOB_TYPE" name="typeCode" :disabled="true"></yu-xform-item>
            <yu-xform-item label="作业代码" ctype="input" name="actionCode" :disabled="true"></yu-xform-item>
            <yu-xform-item label="作业名称" ctype="input" name="actionName" :disabled="true"></yu-xform-item>
            <yu-xform-item label="作业编号" ctype="input" name="sequence" :disabled="true"></yu-xform-item>
            <yu-xform-item label="返回值" ctype="input" name="retValue" :disabled="true"></yu-xform-item>
            <yu-xform-item label="集群代理名称" ctype="select" name="agentCode" :options="agentIds" :disabled="!updateFlag"></yu-xform-item>
            <yu-tooltip class="item" effect="light" content="执行内容(atr)：执行内容变量替换前" placement="top-start">
              <yu-xform-item label="执行内容(atr)" name="actionExec" ctype="input" :disabled="!updateFlag"></yu-xform-item>
            </yu-tooltip>
            <yu-tooltip class="item" effect="light" content="执行位置(atr)：执行位置变量替换前" placement="top-start">
              <yu-xform-item label="执行位置(atr)" name="actionLoc" ctype="input" :disabled="!updateFlag"></yu-xform-item>
            </yu-tooltip>
            <yu-tooltip class="item" effect="light" content="执行内容(wrk)：执行内容变量替换后" placement="top-start">
              <yu-xform-item label="执行内容(wrk)" name="actionExecWrk" ctype="input" :disabled="true" v-if="!isHistory"></yu-xform-item>
            </yu-tooltip>
            <yu-tooltip class="item" effect="light" content="执行位置(wrk)：执行位置变量替换后" placement="top-start">
              <yu-xform-item label="执行位置(wrk)" name="actionLocWrk" ctype="input" :disabled="true" v-if="!isHistory"></yu-xform-item>
            </yu-tooltip>
            <yu-xform-item label="执行结果" name="jobStateStr" ctype="input" :disabled="true"></yu-xform-item>
            <yu-xform-item label="开始时间" name="beginTimeStr" ctype="input" :disabled="true"></yu-xform-item>
            <yu-xform-item label="结束时间" name="endTimeStr" ctype="input" :disabled="true"></yu-xform-item>
            <yu-xform-item label="历史平均执行时长" name="hisAvgTimeStr" ctype="input" :disabled="true"></yu-xform-item>
            <yu-xform-item label="作业优先级" name="actionPrior" ctype="num" :disabled="!updateFlag"></yu-xform-item>
            <yu-xform-item label="错误信息" name="errorMsg" ctype="input" :disabled="true"></yu-xform-item>
          </yu-xform-group>
        </yu-xform>
      </yu-tab-pane>
      <yu-tab-pane label="作业参数信息" v-if="!updateFlag">
        <yu-xtable selection-type="checkbox" ref="refTableExec" :pageable="false" height="410px" :data="wftParList">
          <yu-xtable-column prop="paramName" label="参数名称" :disabled="true"></yu-xtable-column>
          <yu-xtable-column prop="paramValue" label="参数值" :disabled="true"></yu-xtable-column>
          <yu-xtable-column prop="remark" label="备注" :disabled="true"></yu-xtable-column>
        </yu-xtable>
      </yu-tab-pane>
      <yu-tab-pane label="作业日志信息" v-if="!updateFlag">
        <yu-input type="textarea" :rows="4" :account="true" class="forminput" placeholder="日志信息" v-model="logText" readonly></yu-input>
      </yu-tab-pane>
      <yu-tab-pane label="作业事件信息" v-if="!updateFlag">
        <yu-xtable row-number selection-type="checkbox" ref="refTableEvents" :pageable="false" :data="useEventLogList" height="410px">
          <yu-xtable-column prop="eventName" ctype="input" label="事件名称" :disabled="true"></yu-xtable-column>
          <yu-xtable-column ctype="select" prop="relation" label="关联关系" data-code="USE_EVT_REL_TYPE" :disabled="true"></yu-xtable-column>
          <yu-xtable-column ctype="input" prop="eventAppname" label="事件系统" :disabled="true"></yu-xtable-column>
          <yu-xtable-column prop="recordTimeStr" ctype="input" label="事件产生时间" :disabled="true"></yu-xtable-column>
          <yu-xtable-column ctype="input" prop="reamrk" label="备注" :disabled="true"></yu-xtable-column>
        </yu-xtable>
      </yu-tab-pane>
    </yu-tabs>
    <div class="yu-grpButton">
      <yu-button type="primary" @click="jobParamSave" v-if="updateFlag">保存</yu-button>
      <yu-button type="primary" @click="visible = false">关闭</yu-button>
    </div>
  </yu-xdialog>
  <yu-xdialog title="查看设置预置返回值" width="450px" height="140px" :visible.sync="preValueDialogVisible">
    <yu-xform ref="preValueForm" v-model="preValueFormdata" label-width="100px">
      <p style="margin-bottom: 15px; text-align: center; font-size: 12px;">请输入0 ~ 255之间的整数</p>
      <yu-xform-group :column="1">
        <yu-xform-item label="预置返回值" ctype="input" name="returnValue"></yu-xform-item>
      </yu-xform-group>
      <div class="button-group" style="text-align: center">
        <el-button type="primary" @click="setPreValue">保存</el-button>
        <el-button @click="preValueDialogVisible = false">取消</el-button>
      </div>
    </yu-xform>
  </yu-xdialog>
  <yu-xdialog title="修改返回值" width="450px" height="140px" :visible.sync="showModifyRetValue">
    <yu-xform ref="modifyRetForm" v-model="modifyRetValue" label-width="70px">
      <p style="margin-bottom: 15px; text-align: center; font-size: 12px;">请输入0 ~ 255之间的整数</p>
      <yu-xform-group :column="1">
        <yu-xform-item label="返回值" ctype="input" name="returnValue"></yu-xform-item>
      </yu-xform-group>
      <div class="button-group" style="text-align: center">
        <el-button type="primary" @click="setModifyRetValuee">保存</el-button>
        <el-button @click="showModifyRetValue = false">取消</el-button>
      </div>
    </yu-xform>
  </yu-xdialog>
  <yu-xdialog title="修改优先级" width="450px" height="140px" :visible.sync="showJobPriorValue">
    <yu-xform ref="" v-model="jobPriorValue" label-width="70px">
      <p style="margin-bottom: 15px; text-align: center; font-size: 12px;">请输入0 ~ 9之间的整数</p>
      <yu-xform-group :column="1">
        <yu-xform-item label="优先级" ctype="input" name="jobPrior"></yu-xform-item>
      </yu-xform-group>
      <div class="button-group" style="text-align: center">
        <el-button type="primary" @click="setJobPriorValue">保存</el-button>
        <el-button @click="showJobPriorValue = false">取消</el-button>
      </div>
    </yu-xform>
  </yu-xdialog>
  <yu-xdialog title="干预操作状态" width="50%" height="50%" :visible.sync="showDialog" :show-close="false">
    <yu-xtable ref="refLoadTable" row-number :data="loadData" :pageable="false" height="300px">
      <yu-xtable-column label="应用系统" prop="appName" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="任务名称" prop="groupName" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="作业名称" prop="actionName" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="周期时点" prop="cyclePnt" :show-overflow-tooltip="true"></yu-xtable-column>
      <yu-xtable-column label="操作状态" prop="runState" :show-overflow-tooltip="true"></yu-xtable-column>
    </yu-xtable>
    <div>已完成:{{loadDataCount}}/{{loadData.length}}</div>
    <div class="button-group" style="text-align: center">
      <el-button type="primary" @click="closeDialog">关闭</el-button>
    </div>
  </yu-xdialog>
</div>
<style type="text/css">
  .formHeight {
    height: 410px;
    overflow-y: auto;
  }

  .forminput textarea {
    height: 410px;
  }
  .task-query-form{
	  padding-top: 12px;
  }
  .task-query-form .el-form-item{
	  margin-bottom: 0px!important;
  }
</style>
